package com.example.demo.study.exception;

import java.util.InputMismatchException;
import java.util.Scanner;

// exception 异常处理

public class Study {
    public void show() throws ArithmeticException, InputMismatchException {
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入一个除数：");
        int numb = scanner.nextInt();
        System.out.print("请输入一个被除数：");
        int numb2= scanner.nextInt();
        System.out.println("结果是：" + numb / numb2);
    }
    public static void main(String[] args) {
        Study study = new Study();
        Boolean flag = true;
        do{
            try {
                study.show();
                flag = false;
            }catch (ArithmeticException e){
                System.out.println("除数不能为0");
                flag = true;
            }catch (InputMismatchException e){
                System.out.println("请输入数字");
                flag = true;
            }catch(Exception e){
                System.out.println("其他异常");
                flag = true;
            }finally{
                System.out.println("程序继续执行");
            }
        }while (flag);

    }
}
